<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use DB;
// use App\models\User;
class LoginController extends Controller
{
     public function index()
    {
		 return view('home.index');
    }

    public function gologin()
    {
       return view('home.login');     
    }
     
     public function dologin(Request $request)
     {
        //前台登录处理
        $name=$request->input('login_name');
        $ob=DB::table('user')->where('login_name',$name)->first();
        if($ob){
          if($request->input('password') == $ob->password){
               session(['homeuser' => $ob]);
               return  redirect('home');
          }else{
            return back()->with('msg','登录失败，密码错误'); 
          } 
        }else{
              return back()->with('msg','登录失败，账号不存在'); 
        }
     }
 
    public function loginhomeout()
    {
         //退出删除SESSION
        session()->forget('homeuser');
        return redirect('/home');
    }

      public function goregister()
    {
       return view('home.register');     
    }
}
